var _n51;
var cc__extends = __extends;
var cc__decorate = __decorate;
var cc__importDefault = __importDefault;
Object.defineProperty(exports, "__esModule", {
  value: true
});
var $1$EventManager = require("EventManager");
var s = cc__importDefault($1$EventManager);
var $1$yyComponent = require("yyComponent");
var c = cc__importDefault($1$yyComponent);
var $GameEventType = require("GameEventType");
var $zqcc_OverallSystem = require("zqcc_OverallSystem");
var cc__decorator = cc._decorator;
var ccp_ccclass = cc__decorator.ccclass;
cc__decorator.property;
var def_checkScene = function (t) {
  function _ctor() {
    return null !== t && t.apply(this, arguments) || this;
  }
  cc__extends(_ctor, t);
  _ctor.prototype.start = function () {
    let context = this;
    this.zqcc_show();

    // 监听事件并确保正确的上下文
    s.default.on($GameEventType.EventType.UIEvent.showCheckSceneBtn, () => {
      context && context.node && context.show();
    }, this);

  };
  _ctor.prototype.zqcc_show = function () {
    let context = this;

    // 检查 tt 环境
    if (window.tt && window.tt.checkScene && !$zqcc_OverallSystem.sers().userSrv.getCheckScene()) {
      window.tt.checkScene({
        scene: "sidebar",
        success(response) {
          console.log("check scene success: ", response.isExist);
          if (!response.isExist) {
            context.node.parent = null; // 移除节点父级
          }
        },
        fail(error) {
          console.log("check scene fail:", error);
          context.node.parent = null; // 移除节点父级
        }
      });
    }
    // 检查 ks 环境
    else if (window.ks && window.ks.checkCommonUse) {
      window.ks.checkCommonUse({
        success(response) {
          console.log("设为常用查询结果为：" + response.isCommonUse);
          if (response.isCommonUse) {
            context.node.parent = null; // 移除节点父级
          }
        },
        fail(error) {
          if (error.code === -10005) {
            console.log("暂不支持该功能");
          } else {
            console.log("设为常用查询失败", error.msg);
          }
        }
      });
    }
    // 如果没有环境或功能，则直接移除节点父级
    else {
      context.node.parent = null; // 移除节点父级
    }

  };
  _ctor.prototype.zqcc_showCebianlan = function () {
    $zqcc_OverallSystem.mgrs().soundMgr.playBtnSound(); // 播放按钮声音

    if (window.ks && window.ks.checkCommonUse) {
      let context = this; // 使用更具描述性的变量名

      window.ks.addCommonUse({
        success() {
          console.log("设为常用成功");
          context.node.parent = null; // 移除节点父级
        },
        fail(error) {
          if (error.code === -10005) {
            console.log("暂不支持该功能");
          } else {
            console.log("设为常用失败", error.msg);
          }
        }
      });
    } else {
      // 如果不支持常用功能，则显示侧边栏页面
      $zqcc_OverallSystem.sers().uiSrv.showPage("cebianlan", "cebianlan");
    }

  };
  return cc__decorate([ccp_ccclass], _ctor);
}(c.default);
exports.default = def_checkScene;